set /a startAddr=0x0800E000

set /a offsetAddr=-%startAddr%
echo startAddr is: %startAddr%
srec_cat.exe Output\Y2008.hex -intel -offset %offsetAddr% -o Output\Y2008.bin -binary

set para1=%~1
set arg="Output\Y2008.bin"
FOR %%A IN (%arg%) DO set binSize=%%~zA

echo binSize is: %binSize% 


set /a endAddr=%startAddr%+%binSize%
set /a crcAddr=%endAddr%
set /a CodeSizeAddr=%endAddr%+4

echo endAddr is: %endAddr%
echo crcAddr is: %endAddr%
echo CodeSizeAddr is: %CodeSizeAddr%

srec_cat.exe Output\Y2008.hex -intel -crop %startAddr% %endAddr% -fill 0xFF %startAddr% %endAddr% -o Output\Y2008_FILL.hex -intel

cd Output
DEL Y2008.hex
ren Y2008_FILL.hex Y2008.hex

cd ..
::pause